import datetime as datetime
import random

from flask_apscheduler import json

from common.mysqlUtil import exc_sql, exc_sql2
from common.YmlUtil import YmlUtil
from flask import Blueprint
from RootPath import RootPath
import os
path = os.path.join(RootPath.getRootPath(), "Application.yml")
MySQLconf = YmlUtil().readYml(path,"mysql_test_243")

class peakshift_water_plant():
    def insert(self):
        print("=========ss====peakshift_water_plant========")
        dateTime = ( datetime.datetime.now()).strftime("%Y-%m-%d %H:%M:%S")
        h=( datetime.datetime.now()).strftime("%H")
        value1=0
        if h>7 and h<9:
            value1=str((random.randint(220,260))/1000)
        elif h>11 and h<13:
            value1=str((random.randint(220,270))/1000)
        elif h>18 and h<19:
            value1=str((random.randint(220,290))/1000)
        else:
            value1=str((random.randint(180,210))/1000)

        value2=str((random.randint(196,300))/1000)
        value3=str((random.randint(196,300))/1000)
        value4=str((random.randint(2100,3145))/1000)
        sql1="INSERT INTO `peakshift_water_plant` VALUES ('"
        sql2="', '194', '"
        sql3="');"
        tmp="','"
        sql = sql1+dateTime+sql2+value1+tmp+value2+tmp+value3+tmp+value4+sql3
        print(sql)
        exc_sql2(sql,MySQLconf)
# peakshift_water_plant().insert()